<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        代理内部实现对外部不可见
     -->
     <script>
        const hiddenProperties = ['foo', 'bar']
        const target = {
            foo: 1,
            bar: 2,
            baz: 3 
        }
        const proxy = new Proxy(target, {
            get(target, property) {
                if (hiddenProperties.includes(property)) { // 如果存在就返回undefined
                    return undefined
                } else {
                    return Reflect.get(...arguments)
                }
            },

            has(target, property) {
                if (hiddenProperties.includes(property)) {
                    return undefined
                } else {
                    return Reflect.has(...arguments)
                }
            }
        })

        // get()
        console.log(proxy.foo) // undefined
        console.log(proxy.baz) // 3 

        // has()
        console.log('foo' in proxy) // false
        console.log('baz' in proxy) // true
     </script>
</body>
</html>